package com.project.controller;


import com.project.order.OrderService;
import com.project.pojo.User;

import com.project.feign.ssd;


import com.project.utils.ResponseData;
import com.project.utils.ResponseDataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;
import java.util.concurrent.CompletableFuture;

@RestController
@RequestMapping("/redis")
public class RedisTest {
    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    public OrderService orderService;

    @Autowired
    private ThreadPoolTaskScheduler threadPoolTaskScheduler;


    Calendar cal = Calendar.getInstance();
    @RequestMapping("/getKey")
    public String getKey(){
        Integer str=(Integer) redisTemplate.opsForValue().get("s1");
        System.out.println(str);

        return str+"";
    }

    @RequestMapping("/setKey")
    public String setKey(){
        redisTemplate.opsForValue().set("test",1);

        User user = new User();

        return "ss";
    }

    @RequestMapping("/zsetTest")
    public ResponseData getZset(){


        orderService.pushOrder(12,System.currentTimeMillis()+10000);


        CompletableFuture<Void> voidCompletableFuture=CompletableFuture.runAsync(()->{
            orderService.pullOrder();
        },threadPoolTaskScheduler);

        return ResponseDataUtil.buildOk(200,"成功");
    }
}
